package ch.ffhs.bscinf2009.organizeanything.data;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


@SuppressWarnings({ "javadoc", "serial" })
/**
 * @author lir
 * See AbstractType for javadoc
 */
public class DateType extends AbstractType {
	
	private Date data;
	public static DateFormat df = new SimpleDateFormat("dd.MM.yyyy");

	public DateType(String string) {
		try {
			data = df.parse(string);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public DateType() {
	}
	
	@Override
	public String displayValue() {
		if(data==null){
			return "";
		}
		return df.format(data);
	}
	
	public void setData(Date data) {
		this.data = data;
	}
	
	public void setData(String data){
		try {
			this.data = df.parse(data);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	
	public String getData() {
		return df.format(data);
	}

	@Override
	public void parseTypeDefinition(String definition) {
		
	}

	@Override
	public String buildTypeDefinition() {
		return "";
	}


}
